﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace BaseData.HelperEzui
{
    public class TreeNodes
    {
        /// <summary>
        /// 根节点
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        public List<EzuiTreeView<T>> GetRoot<T>(List<EzuiTreeView<T>> items)
        {
            return new List<EzuiTreeView<T>> { new EzuiTreeView<T> {
                    id = 0,
                    text = "根节点",
                    attributes = new Attributes { key = 0, value = 0, },
                    children = items,
                } };
        }
        /// <summary>
        /// 当前节点状态
        /// </summary>
        /// <param name="nodes"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetState<T>(IQueryable<EzuiTreeView<T>> nodes, int id)
        {
            return (!nodes.Any() || id == 0 ? Enums.TreeStat.Open : Enums.TreeStat.Closed).ToString().ToLower();
        }
    }
}
